package com.hon.legionnaire.negocio.vo;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
@Table(name = "funcionario")
@SequenceGenerator(name = "funcionario_seq", sequenceName = "funcionario_cod_funcionario_seq", allocationSize = 1)
@NamedQueries ({	
	@NamedQuery(name = "loadAllFuncionario", query = "from FuncionarioVO"),
	@NamedQuery(name = "findFuncionario", query = "from FuncionarioVO as c where c.codigo = :codigo"),
	@NamedQuery(name = "findDuplicatedFuncionario", query = "from FuncionarioVO as c where c.cpf = :cpf and c.codigo != :codigo")
})
public class FuncionarioVO extends PessoaVO implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@Column(name = "cod_funcionario")
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "funcionario_seq")
	private int codigo;
	
	@Column(name = "rg", length = 12)
	private String rg;
	
	@Column(name = "cpf", length = 15, unique = true)
	private String cpf;
	
	@Column(name = "ctps", length = 20)
	private String ctps;
	
	@Column(name = "dataAdmissao")
	private Date dataAdmissao;
	
	@Column(name = "dataDemissao")
	private Date dataDemissao;
	
	@Column(name = "salario")
	private Float salario;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "cod_cargo")
	@Fetch(FetchMode.JOIN)
	private CargoVO cargoVO;
	
	@Column(name = "status")
	private int status;
	
	@Column(name = "ativo", nullable = false)
	private boolean ativo;
		
	public Date getDataAdmissao() {
		return dataAdmissao;
	}

	public void setDataAdmissao(Date dataAdmissao) {
		this.dataAdmissao = dataAdmissao;
	}

	public Date getDataDemissao() {
		return dataDemissao;
	}

	public void setDataDemissao(Date dataDemissao) {
		this.dataDemissao = dataDemissao;
	}

	public String getCtps() {
		return ctps;
	}

	public void setCtps(String ctps) {
		this.ctps = ctps;
	}
	public Float getSalario() {
		return salario;
	}

	public void setSalario(Float salario) {
		this.salario = salario;
	}

	public CargoVO getCargoVO() {
		return cargoVO;
	}

	public void setCargoVO(CargoVO cargoVO) {
		this.cargoVO = cargoVO;
	}

	public int getCodigo() {
		return codigo;
	}

	public void setCodigo(int codigo) {
		this.codigo = codigo;
	}

	public String getRg() {
		return rg;
	}

	public void setRg(String rg) {
		this.rg = rg;
	}

	public String getCpf() {
		return cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	public FuncionarioVO(int codigo, String nome, String telefone1,
			String telefone2, String celular, String email, String comentario,
			Date dataCriacao, Date dataAlteracao, int codigo2, String rg,
			String cpf) {
		super(codigo, nome, telefone1, telefone2, celular, email, comentario,
				dataCriacao, dataAlteracao);
		codigo = codigo2;
		this.rg = rg;
		this.cpf = cpf;
	}

	public FuncionarioVO() {
		super();
		// TODO Auto-generated constructor stub
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
	public boolean getAtivo() {
		return ativo;
	}

	public void setAtivo(boolean ativo) {
		this.ativo = ativo;
	}
			
}